<?php

require "Autoload.php";
require_once 'function.php';


$key = 'mpjxkljkdgjlfdlljdfgrijfdsgkgkkasw';
$sign =  $key.time();

$url = 'http://mpjx.phasercn.com/api/getOrderData';
//'re2020101015091810002'
$orderId = $_GET['orderid'];
if(empty($orderId)){
    echo '参数错误！';exit;
}
$postdata = [
    'order_id' => $orderId,
    'sign' => md5($sign)
];

$data = json_decode(curl_post( $url, $postdata),true);

//var_dump($data);
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" >
<title></title>
<link rel="stylesheet" href="./static/css/layui.css" media="all" />
<link rel="stylesheet" href="./static/css/style.css" media="all" />
</head>
<body>
    <div class="layui-container">
        <div class="layui-row ">
            <div class="info-box ">
                <h3>订单号：<?= $orderId ?></h3>
            </div>
            <div class="info-box ">
                <h3>金额：<?= empty($data['data']['money']) ? '' : $data['data']['money']?></h3>
            </div>
        </div>
        <div class="layui-row info-box">
           
            <form class="layui-form" method="post" action="pay.php">
                <div class="layui-form-item">
                    <label class="layui-form-label">真实姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="payer_name" id="payer_name" required  lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input" value="<?= empty($data['data']['user']['real_name']) ? '' : $data['data']['user']['real_name'] ?>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id_no" id="id_no" required lay-verify="required" placeholder="请输入身份证号" autocomplete="off" class="layui-input"  value="<?= empty($data['data']['user']['card_id']) ? '' : $data['data']['user']['card_id']?>">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">银行卡号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="bank_card_no" id="bank_card_no" required lay-verify="required" placeholder="请输入银行卡号" autocomplete="off" class="layui-input"  value="<?= empty($data['data']['user']['bank_no']) ? '' : $data['data']['user']['bank_no'] ?>">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">预留手机号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="mobile_no" id="mobile_no" required lay-verify="required" placeholder="请输入银行预留手机号" autocomplete="off" class="layui-input"  value="<?= empty($data['data']['user']['phone']) ? '' : $data['data']['user']['phone'] ?>">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">获取验证码</label>
                    <div class="layui-input-inline" style="position:relative">
                        <input type="text" name="sms_code" id="sms_code" required lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input"  value="">
                        <a href="javascript:void(0);" id="gSMS" onclick="get_sms_captcha('2')" style="font-size: 0.6rem;color: #444;left: 0.5rem;position:absolute;left:70%;top:25%">获取验证码</a> 
                    </div>
                </div>
                <input type="hidden" name="mch_order_no" id="mch_order_no" value="<?= $orderId?>">

                <input type="hidden" name="mch_order_nos" id="mch_order_nos" value="<?= 'rd'.time().rand(5555,9999)?>">


                <input type="hidden" name="order_desc" id="order_desc" value="<?= $orderId?>">
                <input type="hidden" name="callback_param" id="callback_param" value="<?= $orderId?>">
                <input type="hidden" name="return_url" id="return_url" value="<?= empty($data['data']['return_url']) ? '' : $data['data']['return_url']?>">
                
                <input type="hidden" name="order_amount" id="order_amount" value="<?= empty($data['data']['money']) ? '' : $data['data']['money']?>">
               
                <input type="hidden" name="is_paid" id="is_paid" value="<?= empty($data['data']['is_paid']) ? '0' : $data['data']['is_paid']?>">

                
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <!-- <button id="b01" type="button">获取短信</button> -->
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即支付</button>
                    </div>
                </div>
               
            </form>
        </div> 
    </div> 
    
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>


<script>

var countDownT = 60;
function get_sms_captcha(type){
    countDownT = 60;
    setTime();
    //下方写业务

   // $(document).ready(function(){
  //$("#b01").click(function(){
        var payer_name=$("#payer_name").val();
        var id_no=$("#id_no").val();
        var bank_card_no=$("#bank_card_no").val();
        var mobile_no=$("#mobile_no").val();
        //var payer_name=$("#sms_code").val();
        var mch_order_no=$("#mch_order_no").val();
        var mch_order_nos=$("#mch_order_nos").val();
        var order_desc=$("#order_desc").val();
        var callback_param=$("#callback_param").val();
        var order_amount=$("#order_amount").val();
        var is_paid=$("#is_paid").val();
       // var return_url=$("#return_url").val();
        
        $.post("paysms.php",
             {payer_name:payer_name,
            id_no:id_no,
            bank_card_no:bank_card_no,
            mobile_no:mobile_no,
            mch_order_no:mch_order_no,
            mch_order_nos:mch_order_nos,
            order_desc:order_desc,
            callback_param:callback_param,
            order_amount:order_amount,
            is_paid:is_paid
           
        },
        function(result){
          
           alert(result);
         });
  //  });
//});
  
}

function  setTime(){
    if (countDownT == 0){
        $("#gSMS").attr("onclick","get_sms_captcha('2')");
        $("#gSMS").text("获取短信验证码");
    } else{
        $("#gSMS").attr("onclick","#");
        $("#gSMS").text("重新发送("+countDownT+")");
        countDownT--;
        setTimeout(function () {
            setTime();
        },1000)
    }
}



 
</script>
</html>